lappend auto_path /media/data/yi/simulation/dev/tkMD/1.1
package require SimTask 1.1

#argument parsing 
if { [llength $argv] == 1 } {
  set protocol [lindex $argv 0]
  if ![file exists $protocol.tcl] { error "Do not have $protocol.tcl under current folder!"}
} else {
   puts "Usage example: whamrun.tcl protocol \[pdblist\]"
  exit
}

namespace import SimTask::*
set SimTask::PdbPath [pwd]/../pdb
set SimTask::TemplatePath [pwd]/template
set SimTask::JobPath [pwd]/job
set SimTask::RunPath [pwd]/$protocol
set SimTask::Njobs 12
printEnv
set SimTask::Charmmbin /usr/local/bin/charmm

set peptides { 2mlt 2mag 1f0d 1f0e 1f0f }
set type { neutral anionic}
array set anfr_table { anionic 0.3 low_anionic 0.1 high_anionic 1.0 neutral 0.0}
set temp 298
set thick 26
set ionc 0.1
set anfr @anfr_table(@type)
set preptime 5
set eqltime 10
set orientation o0
set force 5.0
source $protocol.tcl

set com {}
for { set i  $wlo } { $i <= $whi } { set i [expr $i +($whi-$wlo)/($nbins-1)] } {
lappend com $i
}


VarSpace options { type com force temp thick ionc anfr anfr_table orientation preptime eqltime }
foreach peptide $peptides {
	prepfiles $peptide {o0.crd o1.crd o2.crd o3.crd o4.crd pept.psf}
	run $nreplica $peptide run.inp options --autopath array(key)_value/ --combine run orientation
}
rmfiles $SimTask::RunPath  *.out
